<template>
	<view>
		<view class="img" v-show="show">
			<image src="../../static/pay/verify_success.png" mode="" v-if="flag"></image>
			<image src="../../static/pay/verify_error.png" mode="" v-else></image>
		</view>
		<view class="status" v-show="show">
			<text v-if="flag">核销成功</text>
			<text v-else>核销失败</text>
		</view>
	</view>
</template>

<script>
	import { getVerify } from '../../api/index.js'
	export default {
		data() {
			return {
				option: {},
				show: false,
				flag: true
			}
		},
		onLoad(option) {
			this.option = option
			this._getVerify()
		},
		methods: {
			_getVerify() {
				uni.showLoading({title: '加载中'})
				let data = {api: this.option.api, ordersn: this.option.ordersn, address: this.option.address}
				getVerify(data, (res) => {
					console.log(res)
					this.show = true
					if (res.code === 3) {
						this.flag = false
						uni.showToast({title: '未登入',icon: 'none'})
						let url = encodeURIComponent(window.location.href)
						window.location.href = 'https://mobile.laiba.shop/activity/visitor/auth?url=' + url
						uni.hideLoading()
						return
					}
					if (res.code === 0) {
						uni.showToast({title: "核销成功",icon: 'none'})
						// this.flag = true
					} else {
						uni.showToast({title: res.message,icon: 'none'})
						this.flag = false
					}
					uni.hideLoading()
				}, (err) => {
					console.log(err)
					uni.showToast({title: "请求失败",icon: 'none'})
					uni.hideLoading()
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.img {
		padding-top: 200rpx;
		text-align: center;
		image {
			width: 200rpx;
			height: 200rpx;
		}
	}
	.status {
		text-align: center;
		font-size: 50rpx;
		color: #2f3030;
	}
</style>
